unit uMainDM;

interface

uses
  SysUtils, Classes, DB, SqlExpr, DBXFirebird,Forms;

type
  TMainDM = class(TDataModule)
    SQLConnection: TSQLConnection;
    procedure SQLConnectionBeforeConnect(Sender: TObject);
    procedure DataModuleCreate(Sender: TObject);
  private
    FDBConnection: TSQLConnection;
    procedure SetDBConnection(const Value: TSQLConnection);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainDM: TMainDM;

implementation
uses uMainForm;
{$R *.dfm}

procedure TMainDM.DataModuleCreate(Sender: TObject);
begin
  if not SQLConnection.Connected then
    SQLConnection.Open;
  TMainForm(Application.MainForm).DBConnection:=SQLConnection;
end;

procedure TMainDM.SetDBConnection(const Value: TSQLConnection);
begin
  FDBConnection := Value;
end;

procedure TMainDM.SQLConnectionBeforeConnect(Sender: TObject);
begin
  SQLConnection.LoadParamsFromIniFile(IncludeTrailingPathDelimiter(
  ExtractFilePath(Application.ExeName))+'dbxconnections.ini');
end;



end.
